/**
 * Created by lx on 2017/5/8.
 */
angular.module('service.template',[
    'ngResource'
])
    .service('TemplateService', ['$http','$resource',function($http,$resource){

        //通过shopid获取template
        this.gettemplate=function(shopid,status,success,error){
            var resource=$resource(shareUrl+"share/template/shopId/:shopId");
            return resource.query({shopId:shopid,status:status},success,error)
        };
        //通过templateid获取share详情
        this.getsharebytemplateId=function(templateId,success,error){
            var resource=$resource(shareUrl+"share/template/:templateId");
            return resource.get({templateId:templateId},success,error)
        };
        //通过templateid获取rule详情
        this.getrulebytemplateId=function(templateId,success,error){
            var resource=$resource(shareUrl+"share/ruler/:templateId");
            return resource.query({templateId:templateId},success,error)
        };
        //生成链接地址
        this.addlink=function(shop,success,error){
            var resource=$resource(shareUrl+"/ShareLink")
            return resource.save(shop,success,error);
        }
        //查看用户的所有分享
        this.getuserallshare=function(userId,shopId,templateId,success,error){
            var resource=$resource(shareUrl+"/ShareLink/getlink/:userId/:shopId/:templateId");
            return resource.query({userId:userId,shopId:shopId,templateId:templateId},success,error)
        };
        //查看用户的有效分享
        this.getuserbystatus=function(status,success,error){
            var resource=$resource(shareUrl+"share/template");
            return resource.query({status:status},success,error)
        };

        ////通过userId和access获取链接地址
        //this.getmyshareaddr=function(userId,access,success,error){
        //    var resource=$resource(shareUrl+"link/addr/:userId/:access")
        //    return resource.get({userId:userId,access:access},success,error);
        //}



    }])